package com.kornero.common.app;

import android.app.Activity;
import android.os.Bundle;

class ExtrasActivity extends Activity {

    protected String getExtraString(final String name) {
        return getExtraString(null, name);
    }

    protected String getExtraString(final Bundle savedInstanceState, final String name) {
        return getExtraString(savedInstanceState, name, null);
    }

    protected String getExtraString(final Bundle savedInstanceState, final String name, final String defaultValue) {
        if (savedInstanceState != null) {
            return savedInstanceState.getString(name, defaultValue);
        } else {
            final Bundle extras = getIntent().getExtras();
            if (extras != null) {
                return extras.getString(name, defaultValue);
            } else {
                return defaultValue;
            }
        }
    }

    protected Long getExtraLong(final String name) {
        return getExtraLong(null, name);
    }

    protected Long getExtraLong(final Bundle savedInstanceState, final String name) {
        return getExtraLong(savedInstanceState, name, null);
    }

    protected Long getExtraLong(final Bundle savedInstanceState, final String name, final Long defaultValue) {
        if (savedInstanceState != null) {
            return savedInstanceState.getLong(name, defaultValue);
        } else {
            final Bundle extras = getIntent().getExtras();
            if (extras != null) {
                return extras.getLong(name, defaultValue);
            } else {
                return defaultValue;
            }
        }
    }
}